package DES

import "fmt"

var maphex = map[string]uint32 {
	"0": 0,
	"1": 1,
	"2": 2,
	"3": 3,
	"4": 4,
	"5": 5,
	"6": 6,
	"7": 7,
	"8": 8,
	"9": 9,
	"a": 10,
	"b": 11,
	"c": 12,
	"d": 13,
	"e": 14,
	"f": 15,
}

func DeToHex(num uint32) string {
	return fmt.Sprintf("%08x", num)
}

func HexToDe(shex string) (re uint32) {
	for i := 0; i < len(shex); i++ {
		re *= 16
		re += maphex[string(shex[i])]
	}
	return
}
